home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 3 / Info_Mac_1994-01.iso / User Interface / General / MacHack Loony Help / tt.c < prev    next >
C/C++ Source or Header  |  1992-06-18  |  2KB  |  120 lines

  1. //
  2. // © 1992 Marc Tamsky
  3. // MacHack '92  Ann Arbor, MI
  4. // Created: Thursday, 18 June.Time: 6:05am after 4 Hours of playing Bolo, Spectre and NetHack!
  5. // LoonyHelp
  6. // a
  7. // nifty little utility for changing the way help baloons work
  8. // i.e. make them animate!
  9.  
  10. /************/
  11. #include <Types.h>
  12. #include <Traps.h>
  13. #include <SysEqu.h>
  14. #include <quickdraw.h>
  15. #include <Menus.h>
  16. #include <Windows.h>
  17. #include <Processes.h>
  18. #include <Resources.h>
  19. #include <Notification.h>
  20. #include <Memory.h>
  21. #include <stdio.h>
  22. #include <Balloons.h>
  23. /************/
  24.  
  25. // #pragma dump "ttdump"   this broke recently.....added more memory....did it help?
  26.  
  27.  
  28. killBalloonMenu()
  29. // not used but included for you fun loving people who love to kill things!
  30. {
  31. MenuHandle    fTesthandle;
  32.  
  33.     if( fTesthandle = GetMHandle(-16490)) 
  34.     {
  35.         DeleteMenu(-16490);
  36.         DisposeMenu(fTesthandle);
  37.     }
  38. }
  39.  
  40. PlotSICN(short SICNid, short index, Point location)
  41. {
  42.     Handle    mySICN;
  43.     BitMap    myImage;
  44.     Rect    myRect;
  45.     int        err;
  46.     
  47.     mySICN = Get1Resource('SICN',SICNid);
  48.     if(err = ResError()) { DebugStr("\pToo bad, couldn't get a needed SICN"); }
  49.     HLock(mySICN);
  50.         myImage.baseAddr = *mySICN + (index - 1 ) * 32;
  51.         myImage.rowBytes = 2;
  52.     
  53.     SetRect(&myRect, location.h, location.v,
  54.                      location.h+16, location.v+16);
  55.     myImage.bounds.left = myRect.left;
  56.     myImage.bounds.right = myRect.right;
  57.     myImage.bounds.top = myRect.top;
  58.     myImage.bounds.bottom = myRect.bottom;
  59.     
  60.     CopyBits(&myImage, &(qd.thePort->portBits), &myRect, &myRect, srcCopy, NULL );
  61.     
  62.     HUnlock(mySICN);
  63. }
  64.  
  65.  
  66. //Notes:
  67. // #define GetGrayRgn() (* (RgnHandle*) 0x09EE)
  68.  
  69. #define MenuList    (short *)*(MenuHandle)*(0xA1C)
  70.  
  71.  
  72. nextIcon()
  73. {
  74. unsigned short            numberOfMenus,balloonEdge;
  75. static int    i=0;
  76. GrafPtr    oldPort,newPort;    
  77. Point    drawPoint;
  78.  
  79.     HLock(*(Handle*)0xA1C);
  80.     numberOfMenus = ***(short ***)(0xA1C);   // actually its nummenus*6
  81.     balloonEdge = *(short*)(**(char ***)(0xA1C) + numberOfMenus - 8 + 6);
  82.     HUnlock(*(Handle*)0xA1C);
  83.  
  84.     GetPort(&oldPort);
  85.         GetWMgrPort(&newPort);
  86.         SetPort(newPort);
  87.  
  88.         OffsetRgn(GetGrayRgn(),0,-MBarHeight);
  89.         drawPoint.h = balloonEdge + 7;
  90.         drawPoint.v = 2;
  91.         i++;
  92.         if (i>7) i=0;
  93.  
  94.                 PlotSICN(128,1+i,drawPoint);
  95.         
  96.         OffsetRgn(GetGrayRgn(),0,MBarHeight);
  97.     SetPort(oldPort);
  98. }
  99.  
  100. main()
  101. {
  102. EventRecord        myEvents;
  103. long    tt;
  104.  
  105.     InitGraf(&qd.thePort);
  106.     InitWindows();
  107.     InitCursor();
  108.  
  109.  
  110.  
  111.     while(!Button()) {
  112.     WaitNextEvent(0,&myEvents,60,0);
  113.     if(HMGetBalloons() && !HMIsBalloon()) {
  114.         nextIcon();
  115.         Delay(5,&tt);
  116.         }
  117.     }
  118. }
  119.  
  120.